
IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[HC_ITEM_UPDATE]') AND TYPE IN (N'P', N'PC'))
DROP PROCEDURE [dbo].[HC_ITEM_UPDATE]
GO

CREATE PROCEDURE [dbo].[HC_ITEM_UPDATE]
(
    @ITEM_NM varchar(100),
    @USR_CRTN_ID VARCHAR(50),
	@ITEM_ID int  output
)
AS

BEGIN
   SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED      
    SET NOCOUNT ON  
	SELECT @ITEM_ID = ITEM_ID FROM DBO.HC_ITEM WHERE ITEM_NM=@ITEM_NM
	IF @ITEM_ID IS NULL
	BEGIN
	INSERT INTO dbo.HC_ITEM
           (
            ITEM_NM,
            USR_CRTN_ID,  
            USR_MDFN_ID 
		)
     VALUES
      (
		  @ITEM_NM,
           @USR_CRTN_ID,
           @USR_CRTN_ID   
		)     
		SELECT @ITEM_ID = SCOPE_IDENTITY()
		
   END
END
GO
